import java.lang.reflect.Array;
import java.util.Arrays;

public class Test1 {
    public static void a(String s) {
        System.out.println("a" + s);
    }
    public static void b(String s) {
        System.out.println("b" + s);
        char[] arr = s.toCharArray();
        String s2 = String.valueOf(arr);

        a(s2);
    }
    public static void main1(String[] args) {
        b("\\\\\\\\");
    }
    public static void main11(String[] args) {
        String s = "        dddd       dddd    ";
        final int[] arr = {1,2,3};
        arr[0] = 3;
        final int a = 2;
//        a = 3;//err
//        arr = new int[20];//err
        /*
        * final 本质是不能改变这个对象所存储的值，而不是不能改变这个对象所指向的其他对象的值
        * 与c语言中的 const int num / int* const arr 类似
        */

        System.out.println(s.trim());
    }
    public static void main10(String[] args) {
        String s = "1234\\056";
        String s1 = s.substring(2);
        System.out.println(s1);
        s1 = s.substring(3, 5);
        System.out.println(s1);
    }
    public static void main9(String[] args) {
        String s = "123-ddd&aaa-2222";
//        String[] ret = s.split("- | &");
        String[] ret = s.split("&");

        for (int i = 0; i < ret.length; i++) {
            String ret2 = ret[i];
            String[] p = ret2.split("-");
            System.out.println(Arrays.toString(p));
        }
        System.out.println(Arrays.toString(ret));
    }
    public static void main8(String[] args) {
        String s = "I am happy";
        String[] arr = s.split(" ");
        System.out.println(Arrays.toString(arr));
        s = "192\\168\\11\\1";
        arr = s.split("\\\\");
        System.out.println(s);
        System.out.println(Arrays.toString(arr));
    }
    public static void main7(String[] args) {
        String s = "11223355";
        char[] arr = s.toCharArray();
        System.out.println(Arrays.toString(arr));
        String s1 = String.format("%d-%d-%d", 1,2,3);
        System.out.println(s1);
        String ret = s.replace("11", "22");
        System.out.println(ret);
        ret = s.replace("1", "22");
        System.out.println(ret);
        ret = s.replace('1', '2');
        System.out.println(ret);
        ret = s.replaceFirst("1", "kkk");
        System.out.println(ret);
    }
    public static void main6(String[] args) {
        String s = "adDCw";
        String ret = s.toUpperCase();
        String ret2 = s.toLowerCase();
        System.out.println(ret);
        System.out.println(ret2);
        System.out.println(s);
    }

    public static void main5(String[] args) {
        String str = "123456";
        int a = Integer.parseInt(str);
        System.out.println(str.charAt(1));
        System.out.println(str.indexOf("234"));
        String str2 = 10.0 + "";
        System.out.println(a + str2);
    }
    static String s3 = "hello";
    static String s4 = "hello";

    public static void main4(String[] args) {
        String s = "1234";
        String s1 = "adc";
        String s2 = "ADC";
        System.out.println(s.compareTo(s1));
        System.out.println(s2.compareToIgnoreCase(s1));
        System.out.println(s.compareToIgnoreCase(s1));
        System.out.println(s2.compareTo(s1));
    }
    public static void main3(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        System.out.println(s1 == s2);
        System.out.println(s3 == s4);
        System.out.println(s1 == s4);
        System.out.println(s1.equals(s2));
        System.out.println(s3.equals(s2));
        System.out.println(s3.equals(s4));
    }
    public static void main2(String[] args) {
        String s1 = "";
        String s2 = null;
        System.out.println(s1.length());
//        System.out.println(s2.length());//error 空指针异常
    }
    public static void main(String[] args) {
        String str1 = new String("1234");
        String str2 = "1ddd";
        char[] arr = {'1', '3', 'i', 'k'};
        String str3 = new String(arr, 1,2);
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
    }
}
